<template>
  <div  style="margin-bottom: 40px ;">
    <div class="charging_rules">
      <div>
        <el-form
          ref="formdatarule"
          :model="formdata"
          :inline="true"
          label-width="150px"
          :rules="formdatarule"
          label-position="top"
          :disabled="disabledType"
        >
          <div
            style="
              height: 50%;
              background: #ffffff;
              margin: 10px 10px 10px 10px;
              padding: 20px;
              border-radius: 10px;
            "
          >
            <!-- 创建的头部 -->
            <div class="rule_title">
              <span class="title-l">
                <i class="icon_left"></i>{{ titleTip }}
                <span
                  v-if="paramsData.Type == 2"
                  style="margin: 0px 0px 0px 20px; color: #f1a357"
                  >{{ formdata.status_name }}</span
                >
              </span>
            </div>
            <div v-if="paramsData.Type == 0 || paramsData.Type == 1" class="receiptManageadd_form_creation" >
              <el-row :gutter="24">
                <el-col :span="24">
                  <el-form-item label="申请原因" prop="apply_reason">
                    <el-input
                      type="textarea"
                      :disabled="disabledType"
                      v-model="formdata.apply_reason"
                      placeholder="请填写申请原因"
                      style="width: 573%"
                    ></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="8" class="row_height_of">
                  <el-form-item label="承运商名称">
                    <span>{{ commonCarrier.account_customer_name }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="8" class="row_height_of">
                  <el-form-item label="对账单号">
                    <span
                      style="cursor: pointer; color: blue"
                      @click="clickToDetail(commonCarrier)"
                      >{{ commonCarrier.account_no }}</span
                    >
                    <span
                      style="
                        color: blue;
                        cursor: pointer;
                        margin: 0px 0px 0px 10px;
                      "
                      @click="diagnose()"
                      >诊断</span
                    >
                  </el-form-item>
                </el-col>
                <el-col :span="8" class="row_height_of">
                  <el-form-item label="是否开具发票">
                    <el-radio v-model="formdata.is_invoiced" label="0"
                      >否</el-radio
                    >
                    <el-radio v-model="formdata.is_invoiced" label="1"
                      >是</el-radio
                    >
                  </el-form-item>
                </el-col>
                <div v-if="formdata.is_invoiced == 1">
                  <el-col :span="8" class="row_height_of">
                    <el-form-item label="发票类型" prop="invoice_type">
                      <el-select
                        placeholder="请选择发票类型"
                        v-model="formdata.invoice_type"
                        style="width: 92%"
                      >
                        <el-option label="专用发票" value="0"></el-option>
                        <el-option label="普通发票" value="1"></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8" class="row_height_of">
                    <el-form-item label="发票金额" prop="invoice_amount">
                      <el-input
                        disabled
                        placeholder="请输入发票金额（含税）"
                        v-model="formdata.invoice_amount"
                      ></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8" class="row_height_of">
                    <el-form-item label="发票税率" prop="invoice_rate_type">
                      <el-select
                        v-model="formdata.invoice_rate_type"
                        placeholder="请选择发票税率"
                        style="width: 92%"
                      >
                        <el-option
                          v-for="item in invoice_rate_list"
                          :key="item.value"
                          :label="item.label"
                          :value="item.value"
                        >
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col
                    :span="8"
                    v-if="formdata.invoice_rate_type == 6"
                    class="row_height_of"
                  >
                    <el-form-item label="发票税率" prop="invoice_rate">
                      <el-input v-model="formdata.invoice_rate"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8" class="row_height_of">
                    <el-form-item
                      label="承运商发票主体"
                      prop="carrier_invoice_body_id"
                    >
                      <el-select
                        style="width: 67%"
                        placeholder="请选择承运商发票主体"
                        filterable
                        @change="selectInvoiceCustomer"
                        v-model="formdata.carrier_invoice_body_id"
                      >
                        <el-option
                          v-for="item in customer_invoice_book_list"
                          :key="item.id"
                          :label="item.invoice_body_name"
                          :value="item.id + ''"
                        >
                        </el-option>
                      </el-select>
                      <el-button class="add-right" @click="AddInvoice"
                        >+</el-button
                      >
                    </el-form-item>
                  </el-col>
                  <el-col :span="8" class="row_height_of">
                    <el-form-item label="纳税人识别号">
                      <el-input
                        placeholder="请输入纳税人识别号"
                        disabled
                        v-model="formdata.taxpayer_identify_number"
                      ></el-input>
                    </el-form-item>
                  </el-col>
                </div>
                <el-col
                  :span="8"
                  class="row_height_of"
                  v-if="formdata.is_invoiced == 0"
                >
                  <el-form-item label="收款人（收款单位）" prop="payee">
                    <el-input v-model="formdata.payee"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="8" class="row_height_of">
                  <el-form-item label="收款银行" prop="receive_bank">
                    <el-input
                      :disabled="disabledpayadd"
                      v-model="formdata.receive_bank"
                    ></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="8" class="row_height_of">
                  <el-form-item label="收款银行卡号" prop="receive_account ">
                    <el-input
                      :disabled="disabledpayadd"
                      v-model="formdata.receive_account"
                    ></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="8" class="row_height_of">
                  <el-form-item label="付款金额(调账后)">
                    <el-input
                      v-model="formdata.payment_amount"
                      disabled
                    ></el-input>
                  </el-form-item>
                </el-col>
                <el-col
                  :span="8"
                  class="row_height_of"
                  v-if="paramsData.Type == 2"
                >
                  <el-form-item label="调账前总金额">
                    <span>{{ formdata.customer_account_old_price }}</span>
                  </el-form-item>
                </el-col>
                <el-col
                  :span="8"
                  class="row_height_of"
                  v-if="paramsData.Type == 2"
                >
                  <el-form-item label="调账差额">
                    <span
                      @click="AdjustmentBalance()"
                      style="color: #409eff; cursor: pointer"
                      >{{ formdata.customer_account_diff_price }}</span
                    >
                  </el-form-item>
                </el-col>
                <el-col :span="8" class="row_height_of">
                  <el-form-item label="是否冲销备用金">
                    <el-radio v-model="formdata.is_used_petty_cash" label="0"
                      >否</el-radio
                    >
                    <el-radio v-model="formdata.is_used_petty_cash" label="1"
                      >是</el-radio
                    >
                  </el-form-item>
                </el-col>
                <el-col
                  :span="8"
                  v-if="formdata.is_used_petty_cash == 1"
                  class="row_height_of"
                  :key="formdata.is_used_petty_cash"
                >
                  <el-form-item label="备用金账号" prop="petty_cash_id">
                    <el-select
                      v-model="formdata.petty_cash_id"
                      placeholder="请输入备用金账号名称"
                      @change="SelectedData"
                      style="width: 92%"
                    >
                      <el-option
                        v-for="item in optionsList"
                        :key="item.id"
                        :label="item.invoice_body_name"
                        :value="item.id"
                      >
                      </el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col
                  :span="8"
                  v-if="formdata.is_used_petty_cash == 1"
                  class="row_height_of"
                >
                  <el-form-item label="备用金余额">
                    <el-input
                      v-model="imprestFund"
                      placeholder="请输入"
                      disabled
                    />
                  </el-form-item>
                </el-col>
                <el-col
                  :span="8"
                  v-if="formdata.is_used_petty_cash == 1"
                  class="row_height_of"
                >
                  <el-form-item label="冲抵备用金" prop="charge_off_money">
                    <el-input
                      v-model="formdata.charge_off_money"
                      type="number"
                      placeholder="请输入"
                    />
                  </el-form-item>
                </el-col>
                <el-col :span="8" class="row_height_of">
                  <el-form-item label="实际报销金额">
                    <el-input
                      disabled
                      v-model="reimbursement"
                      placeholder="请输入"
                    />
                  </el-form-item>
                </el-col>
                <el-col :span="8" class="row_height_of">
                  <el-form-item label="预计付款时间">
                    <el-date-picker
                      v-model="formdata.payment_time"
                      type="datetime"
                      align="right"
                      value-format="timestamp"
                      unlink-panels
                      :picker-options="pickerOptions"
                      style="width: 86%"
                    />
                  </el-form-item>
                </el-col>
                <el-col :span="8" class="row_height_of">
                  <el-form-item label="付款方式" prop="payment_method">
                    <el-select
                      placeholder="请选择付款方式"
                      v-model="formdata.payment_method"
                      style="width: 92%"
                    >
                      <el-option
                        v-for="item in revenue_type_list"
                        :key="item.item_code"
                        :label="item.text"
                        :value="item.value"
                      ></el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <div style="padding: 0px 0px 0px 12px;">
                  <el-form-item
                    label="付款公司主体"
                    prop="company_invoice_body_id"
                  >
                    <el-select
                      style="width: 92%"
                      v-if="formdata.is_invoiced == 0"
                      @change="selectCompanyInvoiceBook"
                      v-model="formdata.company_invoice_body_id"
                    >
                      <el-option
                        v-for="item in company_invoice_book_list"
                        :key="item.id"
                        :label="item.invoice_body_name"
                        :value="item.id + ''"
                      ></el-option>
                    </el-select>
                    <el-select
                      v-else
                      style="width: 92%"
                      @change="selectCompanyInvoiceBook"
                      v-model="formdata.company_invoice_body_id"
                    >
                      <el-option
                        v-for="item in new_data_list_body"
                        :key="item.id"
                        :label="item.invoice_body_name"
                        :value="item.id + ''"
                      ></el-option>
                    </el-select>
                  </el-form-item>
                </div>

                <!-- </el-col> -->
                <el-col :span="16">
                  <el-form-item label="附件" prop="appendix">
                    <UploadLink :files.sync="formdata.appendix"></UploadLink>
                  </el-form-item>
                </el-col>
                <el-col :span="8" v-if="paramsData.Type == 2">
                  <el-form-item label="申请人">
                    <span>{{ formdata.creator_id_name }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="8" v-if="paramsData.Type == 2">
                  <el-form-item label="申请时间">
                    <span v-time="formdata.create_time"></span>
                  </el-form-item>
                </el-col>
              </el-row>
            </div>
            <div v-else  class="receiptManageadd_form_details">
              <el-row :gutter="24">
                <el-col :span="24">
                  <el-form-item label="申请原因" prop="apply_reason">
                    <el-input
                      type="textarea"
                      :disabled="disabledType"
                      v-model="formdata.apply_reason"
                      placeholder="请填写申请原因"
                      style="width: 573%"
                    ></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="8" class="row_height_of">
                  <el-form-item label="承运商名称">
                    <span>{{ commonCarrier.account_customer_name }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="8" class="row_height_of">
                  <el-form-item label="对账单号">
                    <span
                      style="cursor: pointer; color: blue"
                      @click="clickToDetail(commonCarrier)"
                      >{{ commonCarrier.account_no }}</span
                    >
                    <span
                      style="
                        color: blue;
                        cursor: pointer;
                        margin: 0px 0px 0px 10px;
                      "
                      @click="diagnose()"
                      >诊断</span
                    >
                  </el-form-item>
                </el-col>
                <el-col :span="8" class="row_height_of">
                  <el-form-item label="是否开具发票">
                    <span>{{ formdata.is_invoiced_name }}</span>
                  </el-form-item>
                </el-col>
                <div v-if="formdata.is_invoiced == 1">
                  <el-col :span="8" class="row_height_of">
                    <el-form-item label="发票类型" prop="invoice_type">
                      <span>{{ formdata.invoice_type_name }}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8" class="row_height_of">
                    <el-form-item label="发票金额" prop="invoice_amount">
                      <span>{{ formdata.invoice_amount }}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8" class="row_height_of">
                    <el-form-item label="发票税率" prop="invoice_rate_type">
                      <span>{{ formdata.invoice_rate_type_name }}</span>
                    </el-form-item>
                  </el-col>
                  <el-col
                    :span="8"
                    v-if="formdata.invoice_rate_type == 6"
                    class="row_height_of"
                  >
                    <el-form-item label="发票税率" prop="invoice_rate">
                      <span>{{ formdata.invoice_rate }}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8" class="row_height_of">
                    <el-form-item
                      label="承运商发票主体"
                      prop="carrier_invoice_body_id"
                    >
                      <span
                        v-if="formdata.carrier_invoice_body_id_info != null"
                        >{{
                          formdata.carrier_invoice_body_id_info
                            .invoice_body_name
                        }}</span
                      >
                    </el-form-item>
                  </el-col>
                  <el-col :span="8" class="row_height_of">
                    <el-form-item label="纳税人识别号">
                      <span>{{ formdata.taxpayer_identify_number }}</span>
                    </el-form-item>
                  </el-col>
                </div>

                <el-col
                  :span="8"
                  class="row_height_of"
                  v-if="formdata.is_invoiced == 0"
                >
                  <el-form-item label="收款人（收款单位）" prop="payee">
                    <span>{{ formdata.payee }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="8" class="row_height_of">
                  <el-form-item label="收款银行" prop="receive_bank">
                    <span>{{ formdata.receive_bank }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="8" class="row_height_of">
                  <el-form-item label="收款银行卡号" prop="receive_account ">
                    <span>{{ formdata.receive_account }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="8" class="row_height_of">
                  <el-form-item label="付款金额(调账后)">
                    <span>{{ formdata.payment_amount }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="8" class="row_height_of">
                  <el-form-item label="调账前总金额">
                    <span>{{ formdata.customer_account_old_price }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="8" class="row_height_of">
                  <el-form-item label="调账差额">
                    <span
                      @click="AdjustmentBalance()"
                      style=" color: #0000FF; cursor: pointer"
                      >{{ formdata.customer_account_diff_price }}</span
                    >
                  </el-form-item>
                </el-col>
                <el-col :span="8" class="row_height_of">
                  <el-form-item label="是否冲销备用金">
                    <span>{{ formdata.is_used_petty_cash_name }}</span>
                  </el-form-item>
                </el-col>
                <el-col
                  :span="8"
                  v-if="formdata.is_used_petty_cash == 1"
                  class="row_height_of"
                >
                  <el-form-item label="备用金账号" prop="petty_cash_id">
                    <span>{{ formdata.petty_cash_id_name }}</span>
                  </el-form-item>
                </el-col>
                <el-col
                  :span="8"
                  v-if="formdata.is_used_petty_cash == 1"
                  class="row_height_of"
                >
                  <el-form-item label="备用金余额">
                    <span>{{ imprestFund }}</span>
                  </el-form-item>
                </el-col>
                <el-col
                  :span="8"
                  v-if="formdata.is_used_petty_cash == 1"
                  class="row_height_of"
                >
                  <el-form-item label="冲抵备用金" prop="charge_off_money">
                    <span>{{ formdata.charge_off_money }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="8" class="row_height_of">
                  <el-form-item label="实际报销金额">
                    <span>{{ reimbursement }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="8" class="row_height_of">
                  <el-form-item label="预计付款时间">
                    <span v-time="formdata.payment_time"></span>
                  </el-form-item>
                </el-col>
                <el-col :span="8" class="row_height_of">
                  <el-form-item label="付款方式" prop="payment_method">
                    <span>{{ formdata.payment_method_name }}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="8" class="row_height_of">
                  <el-form-item
                    label="付款公司主体"
                    prop="company_invoice_body_id"
                  >
                    <span
                      v-if="formdata.company_invoice_body_id_info != null"
                      >{{
                        formdata.company_invoice_body_id_info.invoice_body_name
                      }}</span
                    >
                  </el-form-item>
                </el-col>
                <el-col
                  :span="8"
                  v-if="paramsData.Type == 2"
                  class="row_height_of"
                >
                  <el-form-item label="申请人">
                    <span>{{ formdata.creator_id_name }}</span>
                  </el-form-item>
                </el-col>
                <el-col
                  :span="8"
                  v-if="paramsData.Type == 2"
                  class="row_height_of"
                >
                  <el-form-item label="申请时间">
                    <span v-time="formdata.create_time"></span>
                  </el-form-item>
                </el-col>
                <el-col :span="16">
                  <el-form-item label="附件" prop="appendix">
                    <UploadLink :files.sync="formdata.appendix"></UploadLink>
                  </el-form-item>
                </el-col>
              </el-row>
            </div>
          </div>
          <!-- 分摊方式 -->
          <div
            style="
              height: 50%;
              width: 50%;
              background: #ffffff;
              margin: 10px 10px 10px 10px;
              padding: 20px;
              border-radius: 10px;
            "
          >
            <el-form-item label="分摊方式">
              <el-select v-model="formdata.share_type" placeholder="发票类型">
                <el-option
                  v-for="item in share_option"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </el-form-item>
            <el-table
              :data="formdata.share"
              border
              style="width: 100%"
              v-if="formdata.share_type != ''"
            >
              <el-table-column type="index" width="40">
                <template slot="header" slot-scope="scope">
                  <span
                    @click="addShiper(scope)"
                    style="font-size: 20px; text-align: center"
                    >+</span
                  >
                </template>
                <template slot-scope="scope">
                  <div class="remodername">
                    <div class="number">{{ scope.$index + 1 }}</div>
                    <div
                      class="remodercenter el-icon-minus"
                      @click="reduce(scope.$index)"
                    ></div>
                  </div>
                </template>
              </el-table-column>
              <el-table-column prop="share_branch_id" label="分摊部门">
                <template slot="header">
                  <span style="color: red">*分摊部门</span>
                </template>
                <template slot-scope="scope">
                  <el-form-item
                    :prop="'share.' + scope.$index + '.share_branch_id'"
                    :rules="formdatarule.share_branch_id"
                  >
                    <el-select
                      v-model="scope.row.share_branch_id"
                      filterable
                      placeholder="请选择分摊部门"
                      style="margin-top: 18px"
                    >
                      <el-option
                        v-for="item in reqWebsiteData"
                        :key="item.id"
                        :label="item.branch_name"
                        :value="item.id + ''"
                      >
                      </el-option>
                    </el-select>
                  </el-form-item>
                </template>
              </el-table-column>
              <el-table-column
                prop="share_content"
                label="按比例分摊(%)"
                v-if="formdata.share_type == 1"
              >
                <template slot-scope="scope">
                  <el-input v-model="scope.row.share_content"></el-input>
                </template>
              </el-table-column>
              <el-table-column
                prop="share_content"
                label="按金额分摊(元)"
                v-if="formdata.share_type == 0"
              >
                <template slot-scope="scope">
                  <el-input
                    v-model="scope.row.share_content"
                    type="number"
                  ></el-input>
                </template>
              </el-table-column>
            </el-table>
          </div>
        </el-form>
      </div>
      <!-- v-if="paramsData.TageType != 0 && -->
      <div
        class="auditProcess"
        v-if=" Object.keys(AuditDetails).length != 0 "
      >
        <approval
          :AuditDetails="AuditDetails"
          :fatherMethod="fatherMethod"
          style="width: 100%"
          :key="Math.random()"
        ></approval>
      </div>
      <div class="auditProcessbuttom">
        <div style="margin: 5px 0px 5px 0px">
          <div
            v-if="paramsData.TageType == 3 || paramsData.TageType == 4"
            style="text-align: center"
          >
            <el-button @click="AuditCancellation()" type="primary" plain
              >关闭</el-button
            >
            <el-button
              @click="PassAuditadd(1)"
              type="primary"
              v-if="
                paramsData.TageType == 3 &&
                AuditDetails.is_current_user_can_approve == 1
              "
              plain
              :disabled="false"
              >通过</el-button
            >
            <el-button
              @click="PassAuditadd(2)"
              type="primary"
              v-if="
                paramsData.TageType == 3 &&
                AuditDetails.is_current_user_can_approve == 1
              "
              plain
              :disabled="false"
              >驳回</el-button
            >
            <el-button
            @click="PassAuditturn()"
            type="primary"
            v-if="
              paramsData.TageType == 3 &&
              AuditDetails.is_current_user_can_approve == 1
            "
            plain
            :disabled="false"
            >转办</el-button
          >
            <el-button
              type="primary"
              @click="abolish()"
              v-if="
                (localgetdata.user_id == formdata.creator_id ||
                  localgetdata.user_id == 1) &&
                (formdata.status == 1 || formdata.status == 2)
              "
              plain
              >撤回</el-button
            >
            <el-button
              type="primary"
              @click="derivedDataItem()"
              v-if="
                formdata.status == 1 ||
                formdata.status == 2 ||
                formdata.status == 3
              "
              plain
              >导出申请</el-button
            >
            <el-button
            type="primary"
            @click="sattementOF(commonCarrier)"
            v-if="
            formdata.status == 1 ||
            formdata.status == 2 ||
            formdata.status == 3
          "
            plain
            >导出对账单</el-button
           >
            <el-dropdown style="margin: 0px 0px 0px 10px">
              <el-button type="primary" plain>
                更多<i class="el-icon-arrow-down el-icon--right"></i>
              </el-button>
              <el-dropdown-menu slot="dropdown" :append-to-body="false">
                <el-dropdown-item
                  style="width: 70px; text-align: center"
                  v-if="
                    formdata.status == 1 &&
                    localgetdata.user_id == formdata.creator_id
                  "
                >
                  <div style="width: 70px;" @click="pressab()"> 催办</div>
                </el-dropdown-item>
                <el-dropdown-item
                  style="width: 70px; text-align: center"
                  v-if="
                    formdata.status == 1 ||
                    formdata.status == 2 ||
                    formdata.status == 3
                  "
                >
                  <div style="width: 70px;" @click="AddComment()">评论</div>
                </el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </div>
          <div style="text-align: center" v-else>
            <el-button type="primary " @click="countermand()" plain
              >取消</el-button
            >
            <el-button
              type="primary"
              @click="SaveContent('formdatarule', 0)"
              plain
              v-if="paramsData.Type == 0"
              >保存</el-button
            >
            <el-button
              type="primary"
              @click="Savecompile('formdatarule', 0)"
              v-if="paramsData.Type == 1"
              plain
              >保存</el-button
            >
            <el-button
              type="primary"
              @click="SaveContent('formdatarule', 1)"
              v-if="paramsData.Type == 0"
              plain
              >发起审批</el-button
            >
            <el-button
              type="primary"
              @click="Savecompile('formdatarule', 1)"
              v-if="paramsData.Type == 1"
              plain
              >发起审批</el-button
            >
            <el-button
              @click="PassAuditadd(1)"
              type="primary"
              v-if="AuditDetails.is_current_user_can_approve == 1"
              plain
              :disabled="false"
              >通过</el-button
            >
            <el-button
              @click="PassAuditadd(2)"
              type="primary"
              v-if="AuditDetails.is_current_user_can_approve == 1"
              plain
              :disabled="false"
              >驳回</el-button
            >
            <el-button
            @click="PassAuditturn()"
            type="primary"
            v-if="AuditDetails.is_current_user_can_approve == 1"
            plain
            :disabled="false"
            >转办</el-button
          >
            <el-button
              type="primary"
              @click="abolish()"
              v-if="
                (localgetdata.user_id == formdata.creator_id ||
                  localgetdata.user_id == 1) &&
                (formdata.status == 1 || formdata.status == 2)
              "
              plain
              >撤回</el-button
            >
            <el-button
              type="primary"
              @click="derivedDataItem()"
              v-if="
                formdata.status == 1 ||
                formdata.status == 2 ||
                formdata.status == 3
              "
              plain
              >导出申请</el-button
            >
            <el-button
            type="primary"
            @click="sattementOF(commonCarrier)"
            v-if="
            formdata.status == 1 ||
            formdata.status == 2 ||
            formdata.status == 3
          "
            plain
            >导出对账单</el-button
          >
            <el-dropdown
              style="margin: 0px 0px 0px 10px"
              v-if="paramsData.TageType != 0"
            >
              <el-button type="primary" plain>
                更多<i class="el-icon-arrow-down el-icon--right"></i>
              </el-button>
              <el-dropdown-menu slot="dropdown" :append-to-body="false">
                <el-dropdown-item
                  style="width: 70px; text-align: center"
                  v-if="
                    formdata.status == 1 ||
                    formdata.status == 2 ||
                    formdata.status == 3
                  "
                >
                  <div style="width: 70px;" @click="AddComment()">评论</div>
                </el-dropdown-item>
                <el-dropdown-item
                  v-if="
                    formdata.status == 1 &&
                    localgetdata.user_id == formdata.creator_id
                  "
                  style="width: 70px; text-align: center"
                >
                  <div style="width: 70px;" @click="pressab()"> 催办</div>
                </el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </div>
        </div>
      </div>
      <div class="dialog">
        <el-dialog
          title="创建承运商发票主体"
          :visible.sync="dialogVisible"
          width="50%"
        >
          <el-form
            :model="formList"
            label-width="140px"
            ref="formList"
            :rules="formrules"
          >
            <el-form-item label="发票主体名称:" prop="invoice_body_name">
              <el-input
                v-model="formList.invoice_body_name"
                placeholder="请输入发票主体名称"
                style="width: 410px"
              ></el-input>
            </el-form-item>
            <el-form-item label="纳税人识别号:" prop="taxpayer_identify_number">
              <el-input
                v-model="formList.taxpayer_identify_number"
                placeholder="请输入纳税人识别号"
                style="width: 410px"
              ></el-input>
            </el-form-item>
            <el-form-item label="公司地址:" prop="company_address">
              <el-input
                v-model="formList.company_address"
                placeholder="请输入公司地址"
                style="width: 410px"
              ></el-input>
            </el-form-item>
            <el-form-item label="公司电话:" prop="company_phone">
              <el-input
                v-model="formList.company_phone"
                placeholder="请输入公司电话"
                style="width: 410px"
              ></el-input>
            </el-form-item>
            <el-form-item label="开户行:" prop="bank_of_deposit">
              <el-input
                v-model="formList.bank_of_deposit"
                placeholder="请输入开户行"
                style="width: 410px"
              ></el-input>
            </el-form-item>
            <el-form-item label="开户行账号:" prop="account_no">
              <el-input
                v-model="formList.account_no"
                placeholder="请输入开户行账号"
                style="width: 410px"
              ></el-input>
            </el-form-item>
            <el-form-item
              label="关联渡石发票主体:"
              prop="relation_invoice_body_id"
            >
              <el-select
                v-model="formList.relation_invoice_body_id"
                placeholder="请选择关联渡石发票主体"
                filterable
                multiple
                style="width: 410px"
              >
                <el-option
                  v-for="item in formListoptions"
                  :key="item.id"
                  :label="item.invoice_body_name"
                  :value="item.id + ''"
                >
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item>
              <el-button
                data-tracker="P58-4"
                type="primary"
                plain
                @click="dialogVisibleflase()"
                >取消</el-button
              >
              <el-button
                data-tracker="P58-4"
                type="primary"
                plain
                @click="establish('formList')"
                >保存</el-button
              >
            </el-form-item>
          </el-form>
        </el-dialog>
      </div>
      <div class="commentdialog">
        <el-dialog
          title="添加评论"
          :visible.sync="commdialogVisible"
          width="30%"
        >
          <div>
            <quillLink
              :AuditDetails="AuditDetails"
              ref="quilldata"
              @showCityName="updateCity"
            ></quillLink>
          </div>
          <div style="margin: 10px 0px 0px 0px; display: flex">
            <UploadLink :files.sync="recordex.annex"></UploadLink>
          </div>
          <div slot="footer" class="dialog-footer" style="text-align: center">
            <el-button @click="commdialogVisible = false">取 消</el-button>
            <el-button type="primary" @click="preserveComment()"
              >确 定</el-button
            >
          </div>
        </el-dialog>
      </div>
      <div class="auditOpinion">
        <el-dialog
          title="审核意见"
          :visible.sync="auditOpinionVisble"
          width="30%"
        >
          <div style="margin-bottom: 10px">
            <el-input
              v-model="opinionFile.opinion"
              :rows="4"
              type="textarea"
            ></el-input>
          </div>
          <div class="uploadList">
            <el-upload
              action
              :auto-upload="false"
              list-type="picture-card"
              :before-remove="beforeRemove"
              :on-preview="handlePreview"
              :on-remove="handleRemove"
              :on-change="handleChange"
              :file-list="fileListList"
            >
              <i class="el-icon-plus"></i>
            </el-upload>
          </div>
          <div></div>
          <div slot="footer" class="dialog-footer" style="text-align: center">
            <el-button type="primary" @click="PassAuditcancel()"
              >取消</el-button
            >
            <el-button
              @click="PassAudit()"
              type="primary"
              v-if="PassAuditsucced == 1"
              plain
              >审核通过</el-button
            >
            <el-button
              @click="ReviewAudit()"
              type="primary"
              v-if="PassAuditsucced == 2"
              plain
              >审核驳回</el-button
            >
          </div>
        </el-dialog>
      </div>
      <!-- 催办  -->
      <div class="presstodo">
        <el-dialog title="选择催办人" :visible.sync="outerVisible">
          <div>
            <el-transfer
              v-model="outerVisibleList"
              :props="{
                key: 'id',
                label: 'name',
              }"
              :data="AuditDetails.urge_relation_user"
              :titles="['全选', '已选']"
            >
            </el-transfer>
          </div>
          <div slot="footer" class="dialog-footer">
            <el-button @click="outerVisible = false">取 消</el-button>
            <el-button type="primary" @click="outerVisibleconfirm()"
              >确定</el-button
            >
          </div>
        </el-dialog>
      </div>
      <!--诊断  -->
      <!--诊断  -->
      <div class="diagnosedata">
        <el-dialog title="诊断" :visible.sync="diagnosedatalog" width="80%">
          <div>
            <el-table
              :data="diagnoseListe"
              sum-text="汇总"
              show-summary
              :summary-method="getSummaries"
              style="width: 100%; overflow: auto"
              :height="tableHeight"
            >
              <el-table-column
                prop="waybill_no"
                label="运单号"
                width="150"
                fixed
              >
                <template slot-scope="scope">
                  <span
                    style="color: #409eff; cursor: pointer"
                    @click="wayClick(scope.row)"
                  >
                    {{ scope.row.waybill_no }}
                  </span>
                </template>
              </el-table-column>
              <el-table-column
                prop="customer_id_name"
                label="所属客户"
                width="150"
              >
              </el-table-column>
              <el-table-column
                prop="waybill_product_type_name"
                label="承运类型"
                width="100"
              >
              </el-table-column>
              <el-table-column
              prop="package_type_name"
              label="包装型号"
              width="100"
            >
            </el-table-column>
              <el-table-column
                prop="total_freight"
                label="总运费"
                width="80"
                align="right"
              >
                <template slot-scope="scope">
                  <span
                    style="color: #409eff; cursor: pointer"
                    @click="freightclick(scope.row, '总费用明细', 0)"
                  >
                    {{ scope.row.total_freight }}
                  </span>
                </template>
              </el-table-column>
              <el-table-column prop="adjust_money" label="调账分摊金额" width="100">
                <template slot-scope="scope">
                  <span
                    style="color: #44fb3d; cursor: pointer"
                    @click="AssessedAmount(scope.row, '调账分摊金额', 0)"
                  >
                    {{ scope.row.adjust_money }}
                  </span>
                </template>
              </el-table-column>
              <el-table-column
                prop="total_expense"
                label="总成本"
                width="80"
                align="right"
              >
              </el-table-column>
              <el-table-column
                prop="gross_profit"
                label="毛利润"
                width="80"
                align="right"
              >
                <template slot-scope="scope">
                  <span
                    v-if="scope.row.gross_profit * 1 < 0"
                    style="color: red"
                  >
                    {{ scope.row.gross_profit }}
                  </span>
                  <span v-else> {{ scope.row.gross_profit }} </span>
                </template>
              </el-table-column>
              <el-table-column
                prop="gross_margin"
                label="毛利率"
                width="80"
                align="right"
              >
                <template slot-scope="scope">
                  <span
                    v-if="parseFloat(scope.row.gross_margin) < 0"
                    style="color: red"
                  >
                    {{ scope.row.gross_margin }}
                  </span>
                  <span v-else> {{ scope.row.gross_margin }} </span>
                </template>
              </el-table-column>
              <el-table-column label="揽收" width="180" align="center">
                <el-table-column
                  prop="collect_info.total_expense"
                  label="总费用"
                  align="right"
                  width="80"
                >
                  <template slot-scope="scope">
                    <span
                      style="color: #409eff; cursor: pointer"
                      @click="freightclick(scope.row, '揽收费用明细', 1)"
                    >
                      {{ scope.row.collect_info.total_expense }}
                    </span>
                  </template>
                </el-table-column>
                <el-table-column prop="collect_info.adjust_money" label="调账分摊金额" width="100">
                  <template slot-scope="scope">
                    <span
                      style="color: #44fb3d; cursor: pointer"
                      @click="AssessedAmount(scope.row, '揽收调账分摊金额', 1)"
                    >
                      {{ scope.row.collect_info.adjust_money }}
                    </span>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="collect_info.status"
                  label="状态"
                  width="100"
                >
                  <template slot-scope="scope">
                    <span>{{ scope.row.collect_info.status_name  }}</span>
                  </template>
                </el-table-column>
              </el-table-column>
              <el-table-column label="干线" width="150" align="center">
                <el-table-column
                  prop="dispatch_info.total_expense"
                  label="总费用"
                  align="right"
                  width="80"
                >
                  <template slot-scope="scope">
                    <span
                      style="color: #409eff; cursor: pointer"
                      @click="freightclick(scope.row, '干线费用明细', 2)"
                    >
                      {{ scope.row.dispatch_info.total_expense }}
                    </span>
                  </template>
                </el-table-column>
                <el-table-column prop="dispatch_info.adjust_money" label="调账分摊金额" width="100">
                  <template slot-scope="scope">
                    <span
                      style="color: #44fb3d; cursor: pointer"
                      @click="AssessedAmount(scope.row, '干线调账分摊金额', 2)"
                    >
                      {{ scope.row.dispatch_info.adjust_money }}
                    </span>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="dispatch_info.status
                                "
                  label="状态"
                  width="80"
                >
                  <template slot-scope="scope">
                    <span>{{
                      scope.row.dispatch_info.status_name
                    }}</span>
                  </template>
                </el-table-column>
              </el-table-column>
              <el-table-column label="配送" width="150" align="center">
                <el-table-column
                  prop="distribution_info.total_expense"
                  align="right"
                  label="总费用"
                  width="80"
                >
                  <template slot-scope="scope">
                    <span
                      style="color: #409eff; cursor: pointer"
                      @click="freightclick(scope.row, '配送费用明细', 3)"
                    >
                      {{ scope.row.distribution_info.total_expense }}
                    </span>
                  </template>
                </el-table-column>
                <el-table-column prop="distribution_info.adjust_money" label="调账分摊金额" width="100">
                  <template slot-scope="scope">
                    <span
                      style="color: #44fb3d; cursor: pointer"
                      @click="AssessedAmount(scope.row, '配送调账分摊金额', 3)"
                    >
                      {{ scope.row.distribution_info.adjust_money }}
                    </span>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="distribution_info.status"
                  label="状态"
                  width="80"
                >
                  <template slot-scope="scope">
                    <span>{{
                      scope.row.distribution_info.status_name 
                    }}</span>
                  </template>
                </el-table-column>
              </el-table-column>
              <el-table-column label="回单" width="150" align="center">
                <el-table-column
                  prop="receipt_info.total_expense"
                  align="right"
                  label="总费用"
                  width="80"
                >
                  <template slot-scope="scope">
                    <span
                      style="color: #409eff; cursor: pointer"
                      @click="freightclick(scope.row, '回单费用明细', 4)"
                    >
                      {{ scope.row.receipt_info.total_expense }}
                    </span>
                  </template>
                </el-table-column>
                <el-table-column prop="receipt_info.adjust_money" label="调账分摊金额" width="100">
                  <template slot-scope="scope">
                    <span
                      style="color: #44fb3d; cursor: pointer"
                      @click="AssessedAmount(scope.row, '回单调账分摊金额', 4)"
                    >
                      {{ scope.row.receipt_info.adjust_money }}
                    </span>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="receipt_info.status"
                  label="状态"
                  width="80"
                >
                  <template slot-scope="scope">
                    <span>{{ scope.row.receipt_info.status_name }}</span>
                  </template>
                </el-table-column>
              </el-table-column>
              <el-table-column label="回箱" width="150" align="center">
                <el-table-column
                  prop="box_recycle_info.total_expense"
                  align="right"
                  label="总费用"
                  width="80"
                >
                  <template slot-scope="scope">
                    <span
                      style="color: #409eff; cursor: pointer"
                      @click="freightclick(scope.row, '回箱费用明细', 5)"
                    >
                      {{ scope.row.box_recycle_info.total_expense }}
                    </span>
                  </template>
                </el-table-column>
                <el-table-column prop="box_recycle_info.adjust_money" label="调账分摊金额" width="100">
                  <template slot-scope="scope">
                    <span
                      style="color: #44fb3d; cursor: pointer"
                      @click="AssessedAmount(scope.row, '回箱调账分摊金额', 5)"
                    >
                      {{ scope.row.box_recycle_info.adjust_money }}
                    </span>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="box_recycle_info.status"
                  label="状态"
                  width="80"
                >
                  <template slot-scope="scope">
                    <span>{{
                      scope.row.box_recycle_info.status_name
                    }}</span>
                  </template>
                </el-table-column>
              </el-table-column>
            </el-table>
          </div>
          <div>
            <el-dialog
              width="60%"
              :title="innerText"
              :visible.sync="innerVisible"
              append-to-body
            >
              <div v-if="innerType == 0">
                <el-table :data="updatedData" style="width: 100%">
                  <el-table-column prop="key_1" label="运费" width="180">
                  </el-table-column>
                  <el-table-column prop="key_4" label="送货费" width="180">
                  </el-table-column>
                  <el-table-column prop="key_5" label="提货费" width="180">
                  </el-table-column>
                  <el-table-column prop="key_6" label="装卸费" width="180">
                  </el-table-column>
                  <el-table-column prop="key_8" label="保价费" width="180">
                  </el-table-column>
                  <el-table-column prop="key_9" label="包装费" width="180">
                  </el-table-column>
                  <el-table-column prop="key_10" label="其他费用" width="180">
                  </el-table-column>
                  <el-table-column prop="adjust_reason" label="原因" width="180">
                  </el-table-column>
                </el-table>
              </div>
              <div v-if="innerType == 1">
                <el-table :data="innerList" style="width: 100%">
                  <el-table-column
                    prop="collect_money"
                    label="提货费"
                    width="180"
                  >
                  </el-table-column>
                  <el-table-column
                    prop="delivery_money"
                    label="发货费"
                    width="180"
                  >
                  </el-table-column>
                  <el-table-column prop="handling_money" label="装卸费">
                  </el-table-column>
                  <el-table-column prop="package_money" label="包装费">
                  </el-table-column>
                  <el-table-column
                    prop="airport_pick_money"
                    label="揽收机场提货费"
                    width="180"
                  >
                  </el-table-column>
                  <el-table-column
                    prop="dry_ice_money"
                    label="揽收干冰费"
                    width="180"
                  >
                </el-table-column>
                <el-table-column prop="adjust_reason" label="原因" width="180">
                </el-table-column>
                </el-table>
              </div>
              <div v-if="innerType == 2">
                <el-table :data="innerList" style="width: 100%">
                  <el-table-column prop="expense" label="干线费" width="180">
                  </el-table-column>
                  <el-table-column prop="adjust_reason" label="原因" width="180">
                  </el-table-column>
                </el-table>
              </div>
              <div v-if="innerType == 3">
                <el-table :data="innerList" style="width: 100%">
                  <el-table-column
                    prop="delivery_fee"
                    label="配送费"
                    width="180"
                  >
                  </el-table-column>
                  <el-table-column
                    prop="extra_distribution_fee"
                    label="配送里程费"
                    width="180"
                  >
                  </el-table-column>
                  <el-table-column
                    prop="second_distribution_fee"
                    label="二次配送费"
                  >
                  </el-table-column>
                  <el-table-column prop="waiting_fee" label="配送专车费">
                  </el-table-column>
                  <el-table-column
                    prop="airport_pick_fee"
                    label="配送机场提货费"
                    width="150"
                  >
                  </el-table-column>
                  <el-table-column
                  prop="dry_ice_fee"
                  label="配送干冰费"
                  width="150"
                >
                    </el-table-column>
                    <el-table-column
                    prop="return_box_money"
                    label="返箱费"
                    width="150"
                  >
                  </el-table-column>
                  <el-table-column
                  prop="airport_operate_fee"
                  label="机场操作费"
                  width="150"
                >
                </el-table-column>
                  <el-table-column
                  prop="transfer_fee"
                  label="中转费"
                  width="150"
                >
              </el-table-column>
              <el-table-column prop="adjust_reason" label="原因" width="180">
              </el-table-column>
                </el-table>
              </div>
              <div v-if="innerType == 4">
                <el-table :data="innerList" style="width: 100%">
                  <el-table-column
                    prop="return_receipt_fee"
                    label="回单费用"
                    width="180"
                  >
                  </el-table-column>
                  <el-table-column prop="adjust_reason" label="原因" width="180">
                  </el-table-column>
                </el-table>
              </div>
              <div v-if="innerType == 5">
                <el-table :data="innerList" style="width: 100%">
                  <el-table-column
                    prop="return_box_fee"
                    label="回箱费用"
                    width="180"
                  >
                  </el-table-column>
                  <el-table-column prop="adjust_reason" label="原因" width="180">
                  </el-table-column>
                </el-table>
              </div>
            </el-dialog>
          </div>
          <span slot="footer" class="dialog-footer" style="text-align: center">
            <div>
              <el-button type="primary" @click="derivedDataFoot()"
                >导出</el-button
              >
            </div>
          </span>
        </el-dialog>
        <!-- 调账日志 -->
        <el-dialog
          title="调账日志"
          :visible.sync="dialogVisible_balance"
          width="40%"
        >
          <div v-if="nodeData.length > 0">
            <el-timeline style="padding: 0 20px" :reverse="true">
              <el-timeline-item
                v-for="(activity, index) in nodeData"
                :key="index"
                :timestamp="
                  new Date(Number(activity.create_time) * 1000).toLocaleString()
                "
              >
                <span
                  >{{ activity.content }}操作人：{{ activity.creator }}</span
                >
              </el-timeline-item>
            </el-timeline>
          </div>
          <div v-else>暂无调账</div>
          <span slot="footer" class="dialog-footer">
            <el-button @click="dialogVisible_balance = false">取 消</el-button>
          </span>
        </el-dialog>
      </div>
    </div>
        <!-- 转办 -->
        <div v-if="dialogturn">
          <TurnTohold :audit_id_list="audit_id_list" @listenToChildEvent='showMsgfromChild'  :AuditDetails="AuditDetails"></TurnTohold>
        </div>
              <!-- 调账分摊金额 -->
    <div>
      <el-dialog
      width="60%"
      :title="innerTextamount"
      :visible.sync="innerVisibleamount"
      append-to-body
      >
      <div v-if="innerTypeDatalist.length > 0 ">
        <div v-for="(itme,index) in innerTypeDatalist" style="margin: 0px 0px 10px 0px;">
          <el-tag >{{itme}}</el-tag>
         </div>
      </div>
      <div v-else>
        <el-tag >暂无调账分摊金额</el-tag>
      </div>
    </el-dialog>
    </div>
  </div>
</template>
<script>
import {
  reqApplyForPayment, //新增付款
  reqEditPayment, //编辑付款
  reqPaymentInfo, //付款详情
  reqReceiptBookList,
  reqCustomerCheckLog,
  reqOutPutCarrier,
  invoice_book_box
} from "@/api/finance";
import TurnTohold from "@/components/TurnTohold/TurnTohold.vue"
import quillLink from "@/components/quillLink/quillLink.vue";
import { dictionaryBatch } from "@/api/waybill";
import { uploading, downloadFile } from "@/page/material/common/common";
// import { invoice_book_box } from "@/api/finance";
import UploadLink from "@/components/uploadFile/uploadLink.vue";
import { InvoiceBookoptions, InvoiceBookCreate } from "@/api/information";
import {
  payable_applcreate,
  payable_appldetail,
  payable_applupdate,
  reimburse_apply_export,
  payable_applcancel_review,
  examine_record_send_message,
  finance_customer_diagnosis,
  finance_customer_diagnosis_export,
} from "@/api/paymentrequest";
import {
  record_process_detail,
  examine_record_update,
  examine_comment_create,
  examine_comment_delete,
  payable_apply_export,
  finance_customer_diagnosis_detail,
  customer_diagnosis_reason
} from "@/api/paymentrequest";
import { organizationBox } from "@/api/organization";
import approval from "@/components/approval/approval.vue";
export default {
  name: "reimburelment",
  components: { UploadLink, approval, quillLink ,TurnTohold},
  data() {
    return {
      titleTip: "承运商付款申请",
      invoiceBookList: [], //请求到的列表
      customer_invoice_book_list: [], //发票簿的下拉列表
      company_invoice_book_list: [], //我方发票主体的列表
      revenue_type_list: [
        {
          value: "0",
          text: "现金",
        },
        {
          value: "1",
          text: "银行卡",
        },
        {
          value: "2",
          text: "支票",
        },
        {
          value: "3",
          text: "电汇",
        },
        {
          value: "4",
          text: "汇票",
        },
        {
          value: "5",
          text: "贷记",
        },
        {
          value: "6",
          text: "其他",
        },
      ], //付款方式
      formdata: {
        account_id: "", // 对账单id
        apply_reason: "", // 申请付款原因
        // 是否开具发票
        is_invoiced: "1", // 是否开具发票: 0 否, 1 是
        appendix: [
          // 发票附件列表
        ],
        invoice_type: "1", // 发票类型：0专用，1普通
        invoice_amount: "", // 发票金额，单位：分
        invoice_rate_type: "4", // 发票税率类型: 0 无, 1 3%, 2 6%, 3 9%, 4 13%, 5 其它
        invoice_rate: "", // 发票税率，单位：分
        company_invoice_body_id: "", // 应付方发票主体
        carrier_invoice_body_id: "", // 收款方(承运商)发票主体
        payment_amount: "", // 付款金额=发票金额，单位：分
        is_used_petty_cash: "1", // 是否使用备用金: 0 否, 1 是
        charge_off_money: "0", // 冲销备用金金额，单位：分
        petty_cash_id: "", // 备用金账户id
        payment_method: "3", // 付款方式: 0 现金，1 银行卡，2 支票，3 电汇，5 汇款，6 贷记，7 其他
        payment_time: "", // 付款截止时间，格式为 RFC3339
        payee: "", // 收款人（收款单位）
        receive_bank: "", // 收款银行
        receive_account: "", // 收款银行行号
        receive_account: "", // 收款账号
        cost_type: "", // 成本类型
        is_initiate_audi: "1", // 是否发起审核: 0 否, 1 是
        // =================
        taxpayer_identify_number: "", //纳税人识别号
        // 是否开具发票
        share_type: "0", //分摊方式 0 按金额分摊 1 按比例分摊
        share: [
          {
            share_branch_id: "",
            share_branch_id_name: "",
            share_content: "",
          },
        ],
      },
      formdatarule: {
        apply_reason: [
          { required: true, message: "请填写申请原因", trigger: "blur" },
        ], // 申请原因
        invoice_type: [
          { required: true, message: "请选择发票类型", trigger: "blur" },
        ], // 申请原因
        invoice_amount: [
          {
            required: true,
            message: "请输入发票金额（含税）",
            trigger: "blur",
          },
        ],
        invoice_rate_type: [
          { required: true, message: "请选择发票税率", trigger: "blur" },
        ],
        invoice_rate: [
          { required: true, message: "请输入发票税率", trigger: "blur" },
        ],
        carrier_invoice_body_id: [
          { required: true, message: "请选择承运商发票主体", trigger: "blur" },
        ],
        taxpayer_identify_number: [
          { required: true, message: "请输入纳税人识别号", trigger: "blur" },
        ],
        receive_bank: [
          { required: true, message: "收款银行", trigger: "blur" },
        ],
        receive_account: [
          { required: true, message: "收款银行卡号", trigger: "blur" },
        ],
        petty_cash_id: [
          { required: true, message: "请输入备用金账号名称", trigger: "blur" },
        ],
        charge_off_money: [
          { required: true, message: "冲抵备用金", trigger: "blur" },
        ],
        payment_time: [
          { required: true, message: "预计付款时间", trigger: "blur" },
        ],
        payment_method: [
          { required: true, message: "请选择付款方式", trigger: "blur" },
        ],
        company_invoice_body_id: [
          { required: true, message: "我方发票主体", trigger: "blur" },
        ],
        payee: [{ required: true, message: "收款人", trigger: "blur" }],
        appendix: [{ required: true, message: "附件", trigger: "blur" }],
        share_branch_id: [
          { required: true, message: "请输入分摊部门", trigger: "blur" },
        ],
      },
      paramsData: {}, //页面跳转传递过来的数据

      invoice_rate_list: [
        {
          value: "1",
          label: "1%",
        },
        {
          value: "2",
          label: "3%",
        },
        {
          value: "3",
          label: "6%",
        },
        {
          value: "4",
          label: "9%",
        },
        {
          value: "5",
          label: "13%",
        },
        {
          value: "6",
          label: "其他",
        },
      ],
      imprestFund: 0, //备用金余额
      reimbursement: 0, //实际的报销金额
      pickerOptions: {
        shortcuts: [
          {
            text: "最近一周",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近一个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近三个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
              picker.$emit("pick", [start, end]);
            },
          },
        ],
      },
      formList: {
        invoice_body_name: "", // 发票主体名称
        company_name: "", // 公司名
        taxpayer_identify_number: "", // 纳税人识别号
        company_address: "", // 公司地址
        company_phone: "", // 公司电话
        bank_of_deposit: "", // 开户行
        account_no: "", // 开户行账号
        invoice_body_belong: "", // 发票主体所属：0公司，1客户，2承运商
        belong_to_id: "", // 发票主体所属(公司、客户、承运商)id
        relation_invoice_body_id: [], // 关联公司发票主体id，
      },
      formListoptions: [], //关联渡石发票主体
      dialogVisible: false, //
      formrules: {
        invoice_body_name: [
          { required: true, message: "请填写发票主体名称", trigger: "blur" },
        ], // 发票主体名称
        company_name: [
          { required: true, message: "请填写公司名", trigger: "blur" },
        ], // 公司名
        taxpayer_identify_number: [
          { required: true, message: "请填写纳税人识别号", trigger: "blur" },
        ], // 纳税人识别号
        company_address: [
          { required: true, message: "请填写公司地址", trigger: "blur" },
        ], // 公司地址
        company_phone: [
          { required: true, message: "请填写公司电话", trigger: "blur" },
        ], // 公司电话
        bank_of_deposit: [
          { required: true, message: "请填写开户行", trigger: "blur" },
        ], // 开户行
        account_no: [
          { required: true, message: "请填写开户行账号", trigger: "blur" },
        ], // 开户行账号
        relation_invoice_body_id: [
          {
            required: true,
            message: "请选择关联渡石发票主体",
            trigger: "blur",
          },
        ], // 关联公司发票主体id，客户和承运商字段
      },
      commonCarrier: {
        id: "",
        account_customer_name: "",
        account_no: "",
        account_customer_id: "", //对账单上的客户id
        account_id: "",
        belong_to_id: "", //承运商主体的id
      },
      AuditDetails: {},
      commdialogVisible: false,
      audit_id_list: "",
      recordex: {
        examine_record_id: "", // 审核记录id
        content: "", // 内容
        annex: [], //评论附件
      },
      auditOpinionVisble: false,
      dialogVisibleout: false,
      dialogImageUrl: "",
      fileListList: [], //上传的文件
      opinionFile: {
        opinion: "", //审核意见
        opinion_annex: [],
      },
      PassAuditsucced: "", //
      disabledType: false,
      localgetdata: "",
      new_data_list_body: [],
      // 评论功能
      contentList: {},
      outerVisible: false,
      outerVisibleList: [],
      // 诊断
      diagnosedatalog: false,
      diagnoseListe: [], // 诊断列表
      innerVisible: false,
      innerText: "",
      innerList: [],
      updatedData: [], //总运费
      tableHeight: "", //高度
      disabledpayadd: true,
      // 分摊方式
      share_option: [
        {
          value: "0",
          label: "按金额分摊",
        },
        {
          value: "1",
          label: "按比例分摊",
        },
      ],
      // 分摊部门
      reqWebsiteData: [],
      //
      innerType: "",
      optionsList: [],
      dialogVisible_balance: false,
      nodeData: [],
      dialogturn: false,
      innerTextamount:"调账分摊金额",
      innerVisibleamount:false,
      innerTypeamount:"",
      innerTypeDatalist:[]
    };
  },
  watch: {
    "formdata.invoice_amount": {
      deep: true,
      handler() {
        // this.formdata.payment_amount = this.formdata.invoice_amount
        this.reimbursement =
          this.formdata.invoice_amount - this.formdata.charge_off_money;
      },
    },
    "formdata.is_invoiced": {
      deep: true,
      handler() {
        if (this.formdata.is_invoiced == 0) {
          this.disabledpayadd = false;
          this.formdata.invoice_type = "";
          this.formdata.invoice_amount = "";
          this.formdata.invoice_rate_type = "";
          this.formdata.invoice_rate = "";
          this.formdata.carrier_invoice_body_id = "";
        } else {
          this.disabledpayadd = true;
          this.formdata.invoice_amount = this.formdata.payment_amount;
        }
      },
    },
    "formdata.charge_off_money": {
      deep: true,
      handler() {
        if (this.formdata.is_used_petty_cash == 1) {
          this.reimbursement =
            this.formdata.invoice_amount - this.formdata.charge_off_money;
        }
      },
    },
  },

  filters: {
    afterTime(value) {
      switch (value) {
        case "0":
          return "未对账";
        case "1":
          return "部分对账";
        case "2":
          return "已对账";
      }
    },
  },
  beforeMount(){
    this.invoiceBox();
  },
  async mounted() {
    this.localgetdata = JSON.parse(localStorage.getItem("user"));
    this.paramsData = this.$route.query;
    // await this.invoiceBox(); //备用金账号
    if (this.paramsData.Type == 2) {
      this.disabledType = true;
    }
    if (this.paramsData.Type == 0) {
      this.commonCarrier.account_customer_name =
        this.paramsData.account_customer_name; //承运商名称
      this.commonCarrier.account_no = this.paramsData.account_no;
      this.formdata.payment_amount = this.paramsData.now_price;
      this.formdata.invoice_amount = this.paramsData.now_price;
      this.commonCarrier.belong_to_id = this.paramsData.account_customer_id;
      this.commonCarrier.account_id = this.paramsData.id;
      // 分摊部门内容
      this.formdata.share[0].share_branch_id = this.localgetdata.branch_id + "";
    } else {
      this.payable_appldetailObj();
      if (this.paramsData.TageType == 3) {
        this.audit_id_list = this.paramsData.audit_id;
        this.record_process_detailObj();
      }
    }
    this.beforeOpenDrawer();
    this.InvoiceBookbodyFn(); //关联发票主体
    this.reqWebsiteListFn();
  },
  methods: {
    // 详情接口
    payable_appldetailObj() {
      this.beforeOpenDrawer();
      var param = {
        id: this.paramsData.id,
      };
      payable_appldetail(param).then((res) => {
        this.formdata = { ...res.data };
        this.formdata.payment_time =
          res.data.payment_time == 0 ? "" : res.data.payment_time * 1000;
        this.selectInvoiceCustomer(res.data.carrier_invoice_body_id);
        if (res.data.is_used_petty_cash == 1) {
          this.SelectedData(res.data.petty_cash_id);
        }

        this.commonCarrier.account_customer_name = res.data.carrier_id_name; //承运商名称
        this.commonCarrier.account_no = res.data.apply_no; //对账单号
        this.commonCarrier.account_id = res.data.account_id; // 对账单的id
        this.commonCarrier.belong_to_id = res.data.carrier_id; // 对账单的id
        this.paramsData.audit_id = res.data.examine_id;
        // res.data.examine_id > 0
        if (res.data.status != 0) {
          this.audit_id_list = res.data.examine_id;
          this.record_process_detailObj();
        }
      });
    },
    beforeOpenDrawer() {
      reqReceiptBookList({
        body_belong: "0", //请求我方发票主体公司
        type: "0",
      }).then((result3) => {
        if (result3.code === 10000) {
          this.invoiceBookList = result3.data;
          this.company_invoice_book_list = result3.data;
        }
      });

      reqReceiptBookList({
        body_belong: "2", //请求发票主体客户下拉用这个
        belong_to_id: this.commonCarrier.belong_to_id * 1, //对账单上的客户id
        invoice_body_name: "", //发票主体名
        type: "0",
      }).then((result1) => {
        if (result1.code === 10000) {
          this.customer_invoice_book_list = result1.data;
        }
      });
    },
    selectInvoiceCustomer(val) {
      let piece = this.customer_invoice_book_list.find(
        (item) => item.id == val
      );
      if (piece) {
        this.formdata.taxpayer_identify_number = piece.taxpayer_identify_number;
        this.formdata.receive_bank = piece.bank_of_deposit;
        this.formdata.receive_account = piece.account_no;
        this.formdata.payee = piece.invoice_body_name;
        var new_data = this.company_invoice_book_list.filter((item) =>
          piece.relation_invoice_body_id.includes(item.id.toString())
        );
        this.new_data_list_body = new_data;
      } else {
      }
    },
    // 备用金账号
    async invoiceBox() {
      var param = {
        invoice_body_name: "",
        petty_cash_type: "", // 中通充值申请下拉选择备用金 填 “1”
        carrier_id: this.paramsData.account_customer_id // 承运商付款申请下拉选择备用金 填 入承运商id
      };
      const res = await invoice_book_box(param);
      if (res.code == 10000) {
        this.optionsList = res.data;
      }
    },
    SelectedData(val) {
      var choose = this.optionsList.find((res) => res.id == val);
      if (choose) {
        this.imprestFund = choose.balance;
      }
    },
    selectCompanyInvoiceBook() {
      this.$forceUpdate();
    },
    AddInvoice() {
      this.dialogVisible = true;
    },
    dialogVisibleflase() {
      this.dialogVisible = false;
    },
    // 获取发票主体的下拉
    InvoiceBookbodyFn() {
      var param = {
        body_belong: 0 + "", // 发票主体所属：0公司，1客户，2承运商
        belong_to_id: 0, // 发票主体所属id
        invoice_body_name: "", // 发票主体名
        type: "0",
      };
      InvoiceBookoptions(param).then((res) => {
        if (res.code == "10000") {
          this.formListoptions = res.data;
        }
      });
    },
    establish(formList) {
      this.$refs[formList].validate((valid) => {
        if (valid) {
          var param = {
            ...this.formList,
            type: 0 + "", //0 是其他 1 是备用金
            invoice_body_belong: 2 + "",
            belong_to_id: this.commonCarrier.belong_to_id * 1,
            relation_invoice_body_id: this.formList.relation_invoice_body_id,
          };
          InvoiceBookCreate(param).then((res) => {
            if (res.code == "10000") {
              this.dialogVisible = false;
              this.open1("success", "创建承运商发票主体成功");
              Object.assign(this.$data.formList, this.$options.data().formList);
              location.reload();
            }
          });
        }
      });
    },
    // 保存数据
    SaveContent(formdatarule, type) {
      this.$refs[formdatarule].validate((valid) => {
        if (valid) {
          if (this.formdata.share_type == 0) {
            let total = 0;
            for (let i = 0; i < this.formdata.share.length; i++) {
              total += Number(this.formdata.share[i]["share_content"]);
            }
            if (
              total.toFixed(3) * 1 == this.formdata.payment_amount * 1 &&
              this.formdata.charge_off_money * 1 <=
                this.formdata.payment_amount * 1
            ) {
              var invoice_rate_data = this.invoice_rate_obj(
                this.formdata.invoice_rate_type
              );
              var param = {
                ...this.formdata,
                account_id: this.commonCarrier.account_id,
                company_invoice_body_id:
                  this.formdata.company_invoice_body_id + "",
                is_initiate_audi: type + "", //是否发起审核
                payment_time: this.formdata.payment_time / 1000 + "",
                invoice_rate: invoice_rate_data,
              };
              payable_applcreate(param).then((res) => {
                this.open1("success", "发起审批");
                this.countermand();
                this.cleardata();
              });
            } else {
              if (total.toFixed(3) * 1 != this.formdata.payment_amount * 1) {
                this.open1("warning", "分摊金额等于付款金额");
              } else {
                this.open1("warning", "冲抵备用金不能超过付款金额");
              }
            }
          } else if (this.formdata.share_type * 1 == 1) {
            let total = 0;
            for (let i = 0; i < this.formdata.share.length; i++) {
              total += Number(this.formdata.share[i]["share_content"]);
            }
            if (
              total == "100" &&
              this.formdata.charge_off_money * 1 <=
                this.formdata.payment_amount * 1
            ) {
              var invoice_rate_data = this.invoice_rate_obj(
                this.formdata.invoice_rate_type
              );
              var param = {
                ...this.formdata,
                account_id: this.commonCarrier.account_id,
                company_invoice_body_id:
                  this.formdata.company_invoice_body_id + "",
                is_initiate_audi: type + "", //是否发起审核
                payment_time: this.formdata.payment_time / 1000 + "",
                invoice_rate: invoice_rate_data,
              };
              payable_applcreate(param).then((res) => {
                this.open1("success", "发起审批");
                this.countermand();
                this.cleardata();
              });
            } else {
              if (total != "100") {
                this.open2("warning", "分摊比例为100%");
              } else {
                this.open1("warning", "冲抵备用金不能超过付款金额");
              }
            }
          }
        }
      });
    },
    Savecompile(formdatarule, type) {
      this.$refs[formdatarule].validate((valid) => {
        if (valid) {
          if (this.formdata.share_type == 0) {
            let total = 0;
            for (let i = 0; i < this.formdata.share.length; i++) {
              total += Number(this.formdata.share[i]["share_content"]);
            }
            if (
              total.toFixed(3) * 1 == this.formdata.payment_amount * 1 &&
              this.formdata.charge_off_money * 1 <=
                this.formdata.payment_amount * 1
            ) {
              var invoice_rate_data = this.invoice_rate_obj(
                this.formdata.invoice_rate_type
              );
              var param = {
                ...this.formdata,
                account_id: this.commonCarrier.account_id,
                company_invoice_body_id:
                  this.formdata.company_invoice_body_id + "",
                is_initiate_audi: type + "", //是否发起审核
                payment_time: this.formdata.payment_time / 1000 + "",
              };
              payable_applupdate(param).then((res) => {
                this.open1("success", "发起审批");
                this.countermand();
                this.cleardata();
              });
            } else {
              if (total.toFixed(3) * 1 != this.formdata.payment_amount * 1) {
                this.open1("warning", "分摊金额等于付款金额");
              } else {
                this.open1("warning", "冲抵备用金不能超过付款金额");
              }
            }
          } else if (this.formdata.share_type * 1 == 1) {
            let total = 0;
            for (let i = 0; i < this.formdata.share.length; i++) {
              total += Number(this.formdata.share[i]["share_content"]);
            }
            if (
              total == "100" &&
              this.formdata.charge_off_money * 1 <=
                this.formdata.payment_amount * 1
            ) {
              var param = {
                ...this.formdata,
                account_id: this.commonCarrier.account_id,
                company_invoice_body_id:
                  this.formdata.company_invoice_body_id + "",
                is_initiate_audi: type + "", //是否发起审核
                payment_time: this.formdata.payment_time / 1000 + "",
              };
              payable_applupdate(param).then((res) => {
                this.open1("success", "发起审批");
                this.countermand();
                this.cleardata();
              });
            } else {
              if (total != "100") {
                this.open2("warning", "分摊比例为100%");
              } else {
                this.open1("warning", "冲抵备用金不能超过付款金额");
              }
            }
          }
        }
      });
    },
    cleardata() {
      Object.assign(this.$data.formdata, this.$options.data().formdata);
    },
    countermand() {
      window.history.back();
    },
    open1(typedata, megessdata) {
      this.$message({
        message: megessdata,
        type: typedata,
      });
    },
    // ======
    // 审核的取消按钮
    AuditCancellation() {
      this.$router.push({ name: "auditrecordsList" });
    },
    // 审核通过
    PassAudit() {
      var param = {
        id: this.paramsData.audit_id + "", // 审核记录id
        status: "1", // 是否通过1通过 2打回
        ...this.opinionFile,
      };
      examine_record_update(param).then((res) => {
        if (res.code == "10000") {
          this.open1("success", "审核通过");
          this.auditOpinionVisble = false;
          this.record_process_detailObj();
          Object.assign(
            this.$data.opinionFile,
            this.$options.data().opinionFile
          );
          this.$router.go(-1);
        }
      });
    },
    // 审核驳回
    ReviewAudit() {
      var param = {
        id: this.paramsData.audit_id + "", // 审核记录id
        status: "2", // 是否通过1通过 2打回
        ...this.opinionFile,
      };
      examine_record_update(param).then((res) => {
        if (res.code == "10000") {
          this.open1("success", "驳回成功");
          this.auditOpinionVisble = false;
          this.record_process_detailObj();
          Object.assign(
            this.$data.opinionFile,
            this.$options.data().opinionFile
          );
          this.$router.go(-1);
        }
      });
    },
    // 审核流程接口
    record_process_detailObj() {
      var param = {
        id: this.audit_id_list + "",
      };
      record_process_detail(param).then((res) => {
        this.AuditDetails = res.data || [];
      });
    },
    //   添加评论
    AddComment() {
      this.commdialogVisible = true;
    },
    updateCity(value) {
      this.contentList = value;
    },
    // 保存评论
    preserveComment() {
      this.$refs.quilldata.preserveComment();
      var param = {
        ...this.recordex,
        content: this.contentList.content,
        examine_record_id: this.audit_id_list + "",
      };
      examine_comment_create(param).then((res) => {
        if (res.code == "10000") {
          this.open1("success", "添加评论成功");
          this.record_process_detailObj();
          this.commdialogVisible = false;
          Object.assign(this.$data.recordex, this.$options.data().recordex);
          this.$refs.quilldata.preserveCommentclear();
        }
      });
      var param = {
        examine_id: this.audit_id_list + "",
        receiver_ids: this.contentList.receiver_ids, // 数组int类型的用户id
        content: this.contentList.content, // 评论内容，  催办不用填
        type: "0", // 0评论 1催办
      };
      examine_record_send_message(param).then((res) => {
        this.record_process_detailObj();
        this.commdialogVisible = false;
      });
    },
    // 删除评论
    deletComment(val) {
      var param = {
        id: val.id,
      };
      examine_comment_delete(param).then((res) => {
        this.open1("删除评论成功", "success");
        this.record_process_detailObj();
      });
    },
    // 审核通过
    PassAuditadd(value) {
      this.auditOpinionVisble = true;
      this.PassAuditsucced = value;
    },
    PassAuditcancel() {
      this.auditOpinionVisble = false;
      Object.assign(this.$data.opinionFile, this.$options.data().opinionFile);
    },

    beforeRemove(file, fileList) {
      return this.$confirm("是否删除该图片");
    },
    handlePreview(file) {
      this.dialogImageUrl = file.url;
      this.dialogVisibleout = true;
    },
    handleRemove(file, fileList) {
      const index = this.opinionFile.opinionFile.findIndex(
        (item) => item.uid === file.uid
      );
      index > -1 && this.opinionFile.opinionFile.splice(index, 1);
    },
    handleChange(file, fileList, type) {
      this.fileListList = fileList;
      var filelist = file.raw; //文件
      var filename = file.raw.uid + file.raw.name; //通过 uid和name组成文件的名字
      uploading(filelist, filename, type).then((res) => {
        this.opinionFile.opinion_annex.push({
          name: file.uid + "",
          url: res.res.requestUrls[0],
        });
      });
    },
    fatherMethod() {
      this.record_process_detailObj();
    },
    clickToDetail(val) {
      this.$router.push({
        name: "carrierreconciliation",
        query: { id: val.account_id, dataPage: 1 },
      });
      // window.open(text.href, "_blank");
    },
    invoice_rate_obj(val) {
      var invoice_rate_data = "";
      switch (val * 1) {
        case 1:
          invoice_rate_data = "1%";
          break;
        case 2:
          invoice_rate_data = "3%";
          break;
        case 3:
          invoice_rate_data = "6%";
          break;
        case 4:
          invoice_rate_data = "9%";
          break;
        case 5:
          invoice_rate_data = "13%";
          break;
        case 6:
          invoice_rate_data = this.formdata.invoice_rate;
          break;
      }
      return invoice_rate_data;
    },
    async derivedDataItem() {
      var ids = this.paramsData.id;
      var param = {
        id: ids,
      };
      var res = await payable_apply_export(param);
      if (res.code == 10000) {
        downloadFile(res.data.loaded_url);
        this.$message({
          type: "success",
          message: "导出成功",
        });
      }
    },
    abolish() {
      var param = {
        id: this.formdata.id,
      };
      payable_applcancel_review(param).then((res) => {
        this.countermand();
      });
    },
    updateCity(value) {
      this.contentList = value;
    },
    pressab() {
      this.outerVisible = true;
    },
    outerVisibleconfirm() {
      var param = {
        examine_id: this.audit_id_list + "",
        receiver_ids: this.outerVisibleList.map(Number), // 数组int类型的用户id
        content: "", // 评论内容，  催办不用填
        type: "1", // 0评论 1催办
      };
      examine_record_send_message(param).then((res) => {
        this.record_process_detailObj();
        this.outerVisible = false;
      });
    },
    // 【诊断】
    diagnose() {
      this.diagnosedatalog = true;
      var param = {
        account_id: this.commonCarrier.account_id,
        apply_id: this.formdata.id,
      };
      finance_customer_diagnosis(param).then((res) => {
        this.diagnoseListe = res.data || [];
        if (this.diagnoseListe.length > 5) {
          this.tableHeight = "450px";
        } else {
          this.tableHeight = "";
        }
      });
    },
    getSummaries(param) {
      const { columns, data } = param;
      const sums = {};
      columns.forEach((column) => {
        sums[column.property] = 0;
      });
      var all_margin = 0;
      var all_freight = 0;
      var ctotal_expense_data = 0;
      var ctotal_freight_data = 0;
      var total_expense_data_all = 0;
      var gross_profit_data_all = 0;
      var dtotal_expense_data = 0;
      var bution_expense_data = 0;
      var box_expense_data = 0;
      var rec_expense_data = 0;
      data.forEach((item) => {
        columns.forEach((column, index) => {
          if (column.property in sums) {
            if (column.property === "collect_info.total_expense") {
              // sums[column.property] += this.checkAndParseValue(item.collect_info.total_expense);
              ctotal_expense_data += this.checkAndParseValue(
                item.collect_info.total_expense
              );
              sums[column.property] = ctotal_expense_data.toFixed(2);
            } else if (column.property === "total_freight") {
              // sums[column.property] += parseFloat(item.total_freight);
              ctotal_freight_data += parseFloat(item.total_freight);
              sums[column.property] = ctotal_freight_data.toFixed(2);
            } else if (column.property === "gross_margin") {
              all_margin += parseFloat(item.gross_profit);
              all_freight += parseFloat(item.total_freight);
              if (all_margin && all_freight) {
                sums[column.property] =
                  ((all_margin / all_freight) * 100).toFixed(2) + "%";
              } else {
                sums[column.property] = "";
              }
            } else if (column.property === "total_expense") {
              total_expense_data_all += parseFloat(item.total_expense);
              sums[column.property] = total_expense_data_all.toFixed(2);
            } else if (column.property === "gross_profit") {
              gross_profit_data_all += parseFloat(item.gross_profit);
              sums[column.property] = gross_profit_data_all.toFixed(2);
            } else if (column.property === "dispatch_info.total_expense") {
              dtotal_expense_data += this.checkAndParseValue(
                item.dispatch_info.total_expense
              );
              sums[column.property] = dtotal_expense_data.toFixed(2);
            } else if (column.property === "distribution_info.total_expense") {
              bution_expense_data += this.checkAndParseValue(
                item.distribution_info.total_expense
              );
              sums[column.property] = bution_expense_data.toFixed(2);
            } else if (column.property === "box_recycle_info.total_expense") {
              box_expense_data += this.checkAndParseValue(
                item.box_recycle_info.total_expense
              );
              sums[column.property] = box_expense_data.toFixed(2);
            } else if (column.property === "receipt_info.total_expense") {
              rec_expense_data += this.checkAndParseValue(
                item.receipt_info.total_expense
              );
              sums[column.property] = rec_expense_data.toFixed(2);
            } else {
              sums[column.property] = "";
            }
          } else {
          }
        });
      });
      sums["waybill_no"] = "汇总";
      return Object.keys(sums).map((key) => {
        return sums[key];
      });
    },
    checkAndParseValue(value) {
      const parsedValue = parseFloat(value);
      return isNaN(parsedValue) ? 0 : parsedValue;
    },
    wayClick(value) {
      var id = value.waybill_id;
      let text = this.$router.resolve({
        name: "waybillDetail",
        query: { id, activeName: "1" },
      });
      window.open(text.href, "_blank");
    },
    freightclick(value, text, type) {
      // type 1揽收 2干线 3配送 4回单 5回箱
      this.innerVisible = true;
      this.innerText = text;
      this.innerType = type;
      var param = {
        waybill_id: value.waybill_id,
        node_type: type + "", // 1揽收 2干线 3配送 4回单 5回箱
      };
      finance_customer_diagnosis_detail(param).then((res) => {
        if (type != 0) {
          this.innerList = res.data;
        } else {
          this.updatedData = res.data.map((item) => {
            this.expense_list = {
              key_1: item["1"] == undefined ? 0 : item["1"],
              key_4: item["4"] == undefined ? 0 : item["4"],
              key_5: item["5"] == undefined ? 0 : item["5"],
              key_6: item["6"] == undefined ? 0 : item["6"],
              key_8: item["8"] == undefined ? 0 : item["8"],
              key_9: item["9"] == undefined ? 0 : item["9"],
              key_10: item["10"] == undefined ? 0 : item["10"],
              adjust_reason:item.adjust_reason
            };
            return {
              ...this.expense_list,
            };
          });
        }
      });
    },
    AssessedAmount(value, text, type) {
         // type 1揽收 2干线 3配送 4回单 5回箱
      this.innerVisibleamount = true;
      this.innerTextamount = text;
      this.innerTypeamount = type;
      var param = {
        waybill_id: value.waybill_id,
        node_type: type + "", // 1揽收 2干线 3配送 4回单 5回箱
      };
      customer_diagnosis_reason(param).then((res) => {
        this.innerTypeDatalist = res.data
        console.log(res,"resdfads")
      })
    },
    // 分摊方式
    addShiper() {
      this.formdata.share.push({
        share_branch_id: "",
        share_branch_id_name: "",
        share_content: "",
      });
    },
    reduce(index) {
      if (this.formdata.share.length > 1) {
        this.formdata.share.splice(index, 1);
      } else {
        this.$message({
          message: "这是最后一条数据",
          type: "warning",
        });
      }
    },
    // 分摊部门
    reqWebsiteListFn() {
      let data = {
        pid: 1,
      };
      organizationBox(data).then((res) => {
        if (res.code === 10000) {
          this.reqWebsiteData = res.data;
        }
      });
    },
    derivedDataFoot() {
      var param = {
        account_id: this.commonCarrier.account_id,
        apply_id: this.formdata.id,
      };
      finance_customer_diagnosis_export(param).then((res) => {
        this.reqUrl = "https://" + res.data.loaded_url;
        window.open(this.reqUrl);
      });
    },
    //函数
    parseGrossMargin(grossMarginStr) {
      if (grossMarginStr && grossMarginStr.endsWith("%")) {
        const numericValue = parseFloat(grossMarginStr.replace("%", ""));
        return isNaN(numericValue) ? 0 : numericValue / 100;
      }
      return 0;
    },
    //调账差额
    AdjustmentBalance() {
      this.dialogVisible_balance = true;
      var param = {
        account_id: this.formdata.account_id,
      };
      reqCustomerCheckLog(param).then((res) => {
        this.nodeData = res.data;
      });
    },
    async sattementOF(val) {
      // var ids = this.paramsData.id;
      console.log(val.account_id,"commonCarrier")
      var param = {
        id: val.account_id*1,
      };
      var res = await reqOutPutCarrier(param);
      if (res.code == 10000) {
        console.log(res)
        // var urldata = "https://"
        window.open("https://" + res.data.loaded_url, "_self");
        this.$message({
          type: "success",
          message: "导出成功",
        });
      }
    },
    PassAuditturn() {
        this.dialogturn = true
      },
      showMsgfromChild(data) {
        console.log(data, " this.$emit('listenToChildEvent',this.datalist)")

        if (data.resstatus == 1) {
          this.record_process_detailObj()
          this.$router.go(-1);
        } else {

        }
        this.dialogturn = false
      }
  },
};
</script>
<style scoped lang="less">
/deep/ .uploadList .el-upload--picture-card,
/deep/ .uploadList .el-upload-list__item {
  width: 98px;
  height: 98px;
  line-height: 100px;
}
/deep/ .receiptManageadd_form_details .el-form-item--mini .el-form-item__label {
  line-height: 6px;
}
.receiptManageadd_form_details .row_height_of {
   height: initial;
   font-size: 15px;
}
/deep/ .receiptManageadd_form_details .el-form-item__content  {
   font-weight: bold;
 }
.auditProcessbuttom {
  position: fixed;
  background: #ffffff;
  margin: 10px 10px 10px 10px;
  padding: 10px;
  border-radius: 10px;
  width: calc(100% - 225px);
  z-index: 100;
  bottom: -1.5%;
}

.charging_rules {
  /* padding: 10px;
      margin-top: 5px;
      margin-left: 5px; */
  /* background-color: #fff; */
}

.add-right {
  width: 30px;
  position: relative;
  left: -1%;
  padding: 0;
  height: 28px;
  border-radius: 0 4px 4px 0;
  border-left-width: 0px;
  font-size: 18px;
  font-weight: bold;
  top: 2.3px;
}

.rule_title {
  display: flex;
  align-items: center;
  padding-bottom: 18px;
  padding-top: 8px;
  font-size: 14px;
  font-weight: bold;
  justify-content: space-between;

  .title-l {
    display: flex;
    align-items: center;
  }

  .icon_left {
    display: inline-block;
    width: 6px;
    height: 16px;
    background: #f1a357;
    margin-right: 6px;
  }
}

.remodername .number {
  height: 20px;
  display: block;
}

.remodername:hover .number {
  display: none;
}

.remodername .remodercenter {
  display: none;
  color: #161414;
}

.remodername:hover .remodercenter {
  height: 20px;
  display: block;
  color: #262424;
  text-align: center;
  font-size: 10px;
  padding: 5px 0px 0px 0px;
}

.row_height_of {
  height: 65px;
}
/deep/ .receiptManageadd_form_creation .el-form-item--mini .el-form-item__label {
  line-height: 6px;
}


</style>